package com.dao.impl;

import java.util.List;

public class OrderDao extends HibernateDaoSupport implements IOrderDao{
	
	public Order get(Integer id){
		return getHibernateTemplate().get(Order.class, id);
	}
	
	public Integer save(Order order){
		return (Integer)getHibernateTemplate()
			.save(order);
	}
	
	public void update(Order order){ 
		getHibernateTemplate().update(order);
	}
	
	public void delete(Order order){
		getHibernateTemplate().delete(order);
	}
	
	public void delete(Integer id){
		getHibernateTemplate().delete(get(id));
	}
	
	public List<Order> findAll(){
		return (List<Order>)getHibernateTemplate()
				.find("from Order");
	}

	public List<Order> findByParam(String key) {
		String hql = "from Order o where o.name like '%" + key + "%'";
		return this.getSession()
				.createQuery(hql)
				.list();
	}

}
